package com.itboye.ihomebank.util;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.itboye.ihomebank.R;

@SuppressLint({"NewApi", "ValidFragment"})
public class WriteYanZhengMaDialog extends DialogFragment {

	private String mMsg = "Loading";
	Button buttonOk, buttonCancel;
	private EditText edit;

	public void setMsg(String msg) {
		this.mMsg = msg;
	}

	OnfinishListener onfinishListener;

	public WriteYanZhengMaDialog(OnfinishListener onfinishListener) {
		this.onfinishListener = onfinishListener;
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		LayoutInflater inflater = getActivity().getLayoutInflater();
		View view = inflater.inflate(R.layout.dialog_yanzhengma, null);
		edit = (EditText) view.findViewById(R.id.edit);
		buttonOk = (Button) view.findViewById(R.id.ok);
		buttonOk.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub

				onfinishListener.getEditText(edit.getText().toString());
				dismiss();
			}
		});
		buttonCancel = (Button) view.findViewById(R.id.cancel);
		buttonCancel.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				onfinishListener.cancel();
				dismiss();
			}
		});
		// TextView title = (TextView) view
		// .findViewById(R.id.id_dialog_loading_msg);
		// title.setText(mMsg);
		Dialog dialog = new Dialog(getActivity(), R.style.dialog);
		dialog.setContentView(view);
		dialog.setCanceledOnTouchOutside(false);

		return dialog;
	}

	public EditText getEdit() {
		return edit;
	}

	public interface OnfinishListener {
		void getEditText(String edit);

		void cancel();
	}
}
